<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page contentType="text/html;charset=UTF-8" language="java"
	isELIgnored="false"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<%
	//String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<link rel="stylesheet" type="text/css"
	href="${ctxStatic}/jquery-easyui-1.4.5/themes/default/easyui.css">
<link rel="stylesheet" type="text/css"
	href="${ctxStatic}/jquery-easyui-1.4.5/themes/icon.css">
<script type="text/javascript"
	src="${ctxStatic}/jquery-easyui-1.4.5/jquery.min.js"></script>
<script type="text/javascript"
	src="${ctxStatic}/jquery-easyui-1.4.5/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="${ctxStatic}/jquery-easyui-1.4.5/locale/easyui-lang-zh_CN.js"></script>
<style type="text/css">
body {
	text-align: center;
}

div table {
	margin: 0 auto;
}

.clear {
	clear: both;
}

table .button {
	margin: 0 auto;
	width: 50%;
	padding-top: 3px;
}

table tr, table td {
	padding: 6px;
}

#v_body {
	margin-top: 64px;
	margin-left: 480px;
}

table input {
	width: 100%;
	height: 100%;
	display: inline-table;
}
</style>
<title>登录/注册</title>
</head>
<body>
	<div id="v_body">
		<div style="float: left; margin-right: 20px;">
			<h2>OA办公系统</h2>
			<h3 style="color: #0099FF;">Office Automation</h3>

		</div>
		<div class="easyui-tabs" justified="true"
			style="float: left; width: 360px; height: 380px; margin: 0 auto;">
			<div title="登录"
				style="padding-top: 64px; background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#EFF6FF), to(#fafafa));">
				<div id="login">
					<!-- 登录 -->
					<form id="loginForm" method="post">
						<table border="0">
							<tr>

							</tr>
							<tr>
								<td><input class="easyui-textbox" name="logname"
									id="etxt_name" data-options="iconCls:'icon-man'"
									style="width: 200px; height: 26px"></td>
							</tr>
							<tr>
								<td><input class="easyui-textbox" type="password"
									id="etxt_pwd" name="pwd" data-options="iconCls:'icon-lock'"
									style="width: 200px; height: 26px"></td>
							</tr>
							<tr style="height: 12px;" />
							<tr>
								<td colspan="1" style="text-align: center;"><a
									class="easyui-linkbutton" id="btn_log" style="width: 98%">登录</a>
									<div class="clear" /></td>
							</tr>
						</table>
					</form>
				</div>
			</div>
			<div title="快速注册" closable="flase"
				style="padding-top: 16px; background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#EFF6FF), to(#fafafa));">
				<form id="registForm" method="post">
					<table border="0">
						<tr>
							<td>ID:</td>
							<td><input class="easyui-validatebox" name="uid" type="text"
								missingMessage="请输入ID" data-options="required:true"
								style="width: 200px; height: 22px"></td>
						</tr>
						<tr>
							<td>姓名:</td>
							<td><input class="easyui-validatebox" name="uname"
								type="text" missingMessage="请输入姓名" data-options="required:true"
								style="width: 200px; height: 22px"></td>
						</tr>

						<tr>
							<td>Email:</td>
							<td><input id="vv" class="easyui-validatebox" name="email"
								missingMessage="请输入邮箱"
								data-options="required:true,validType:'email'"
								style="width: 200px; height: 22px" /></td>
						</tr>
						<tr>
							<td>登录名:</td>
							<td><input class="easyui-validatebox" type="text"
								name="logname" missingMessage="请输入登录名"
								data-options="required:true" style="width: 200px; height: 22px">
							</td>
						</tr>
						<tr>
							<td>密码:</td>
							<td><input id="pwd" class="easyui-validatebox"
								type="password" missingMessage="输入密码"
								data-options="required:true" style="width: 200px; height: 22px">
							</td>
						</tr>
						<tr>
							<td>确认密码:</td>
							<td><input id="rpwd" class="easyui-validatebox" name="pwd"
								type="password" missingMessage="确认密码" required="required"
								validType="equals['#pwd']" style="width: 200px; height: 22px">

							</td>
						</tr>
						<tr style="height: 12px;" />
						<tr>
							<td></td>
							<td colspan="1" style="text-align: center;"><a
								class="easyui-linkbutton" id="btn_reg"
								style="width: 90%; height: 28px;">注册</a></td>
						</tr>
					</table>
				</form>
			</div>
		</div>
		<!-- easyui-tabs end -->
		<div class="clear" />
	</div>
</body>
</html>
<script type="text/javascript">
	$(function() {
		//登录
		$("#btn_log").click(function() {
			$('#loginForm').form('submit', {
				url : '${mainPath}/checklog',
				onSubmit : function() {
					// do some check 
					if (("") == $("#etxt_name").val()) {
						return false;
					}
					if (("") == $("#etxt_pwd").val()) {
						return false;
					}
					// return false to prevent submit;    
				},
				success : function(data) {
					var data = eval('(' + data + ')');
					if (data.success) {
						window.location.href = '${mainPath}/sys';
					} else {
						alert(data.msg);
					}
				}
			});
		});

		$.extend($.fn.validatebox.defaults.rules, {
			equals : {
				validator : function(value, param) {
					return value == $(param[0]).val();
				},
				message : '两次输入不一致',
			}
		});

		//注册
		$("#btn_reg").click(function() {
			$('#registForm').form('submit', {
				url : "${mainPath}/reguser",
				onSubmit : function() {

				},
				success : function(data) {
					var data = eval('(' + data + ')');
					if (data.success) {
						alert(data.msg);
						window.location.href = '${mainPath}/sys';
					} else {
						alert(data.msg);
					}
				}
			});
		});

	});
</script>
